<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<% 
  String username=(String) session.getAttribute("UserName");
	  if(username == null)
	  	username = "";
	  if(username.compareTo("admin") == 0 || username.compareTo("anh") == 0 )
	  {
		  //response.sendRedirect("index.jsp");
	  }
	  else
		  response.sendRedirect("ShowNotice2.jsp");
%>

<tiles:insertTemplate template="Template.jsp">

	<tiles:putAttribute name="head">
		<h1>Manager</h1>
	</tiles:putAttribute>

	<tiles:putAttribute name="body">

		<h3 style="text-align: center; color: red;">${errors}</h3>
		<table class="table table-bordered"
			style="width: 90%; margin: 0px auto;">

			<tr bgcolor="lightgray">
				<th>Id</th>
				<th>OrderId</th>
				<th>ProductId</th>
				<th>UnitPrice</th>
				<th>Quantity</th>
				<th>Discount</th>
				<th>&nbsp;</th>
			</tr>
			<c:forEach var="c" items="${orderd.rows}">
				<tr>
					<td>${c.Id}</td>
					<td>${c.OrderId}</td>
					<td>${c.ProductId}</td>
					<td>${c.UnitPrice}</td>
					<td>${c.Quantity}</td>
					<td>${c.Discount}</td>
				</tr>
			</c:forEach>
		</table>
		<h1 style="text-align: center; color: blue">ORDERS</h1>
		<table class="table table-bordered"
			style="width: 90%; margin: 0px auto;">
			<tr align="center">
				<td align="center" colspan="7">
					<form class="form-search" action="OrderServlet" method="post">
						<input type="text" name="txtSearch"
							class="input-medium search-query"> <input type="submit"
							name="btnSearch" class="btn" value="Search">
					</form>
				</td>
			</tr>
			<tr bgcolor="lightgray">
				<th>Id</th>
				<th>CustomerID</th>
				<th>Ordered</th>
				<th>Required</th>
				<th>Shipped</th>
				<th>FullName</th>
				<th>Address</th>
				<th>PaymentMethod</th>
				<th>&nbsp;</th>
			</tr>
			<c:forEach var="c" items="${orders.rows}">
				<tr>
					<td>${c.Id}</td>
					<td>${c.CustomerID}</td>
					<td>${c.Ordered}</td>
					<td>${c.Required}</td>
					<td>${c.Shipped}</td>
					<td>${c.FullName}</td>
					<td>${c.Address}</td>
					<td>${c.PaymentMethod}</td>
					<td><a href="?OderDetails=${c.Id}">OderDetails</a></td>
				</tr>
			</c:forEach>
		</table>




	</tiles:putAttribute>

</tiles:insertTemplate>